<?php

define('_MPDF_PATH','util/MPDF54');
include( _MPDF_PATH. "/mpdf.php");

$fileName = constant('CONST_directorioDocs') . "FormularioPDF.pdf";

if (isset($_POST['fileName'])) {
    $fileName = $_POST['fileName'];
}

$ajax_var1 = '<form> </form>';

if (isset($_POST['varHtml'])) {
    $ajax_var1 = '<form>'. $_POST['varHtml'] .'</form>';
}

if (isset($_REQUEST['html'])) { echo '<html><head><style>'.file_get_contents('mpdfstyletables.css').'</style></head><body>'.$ajax_var1.'</body></html>'; exit; }

if (isset($_REQUEST['source'])) { 
	$file = __FILE__;
	header("Content-Type: text/plain");
	header("Content-Length: ". filesize($file));
	header("Content-Disposition: attachment; filename='".$file."'");
	readfile($file);
	exit; 
}
//==============================================================
//==============================================================
//==============================================================

$mpdf = new mPDF('c'); 

$mpdf->default_lineheight_correction = 1.2;

// LOAD a stylesheet
$stylesheet = file_get_contents( _MPDF_PATH . '/mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet,1);	// The parameter 1 tells that this is css/style only and no body/html/text

$mpdf->SetColumns(1,'J');

$mpdf->WriteHTML($ajax_var1);

if (file_exists($fileName)) {
    unlink($fileName);
}

$mpdf->Output($fileName, "F");
exit;

?>